/*
 ------------------------------------------------------------------------------
 Copyright (C) 2006-2007 Team Blur.

 This file is part of the Quantum Engine source code.

 The Quantum Engine source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The Quantum Engine source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the Quantum Engine source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


#ifndef __FRAMEWORK_SYSTEM_H__
#define __FRAMEWORK_SYSTEM_H__


typedef enum {
	CPUID_UNSUPPORTED				= BIT(0),	// Unsupported CPU (386/486, etc)
	CPUID_GENERIC					= BIT(1),	// Unrecognized CPU
	CPUID_AMD						= BIT(2),	// AMD CPU
	CPUID_INTEL						= BIT(3),	// Intel CPU
	CPUID_MMX						= BIT(4),	// Supports 'Multi Media Extensions'
	CPUID_MMX_EXT					= BIT(5),	// Supports extended 'Multi Media Extensions'
	CPUID_3DNOW						= BIT(6),	// Supports '3DNow!'
	CPUID_3DNOW_EXT					= BIT(7),	// Supports extended '3DNow!'
	CPUID_SSE						= BIT(8),	// Supports 'Streaming SIMD Extensions'
	CPUID_SSE2						= BIT(9),	// Supports 'Streaming SIMD Extensions 2'
	CPUID_SSE3						= BIT(10),	// Supports 'Streaming SIMD Extensions 3'
	CPUID_SSE4						= BIT(11),	// Supports 'Streaming SIMD Extensions 4'
	CPUID_HTT						= BIT(12),	// Supports 'Hyper-Threading Technology'
} cpuId_t;

/*
 ==============================================================================

 FUNCTIONS EXPORTED BY THE ENGINE

 ==============================================================================
*/

typedef struct {
	// Loads the given library from the current game directory. Appends suffix
	// and extension appropriate for the underlying platform.
	// Returns NULL if not found.
	void *					(*LoadLibrary)(const char *libName);

	// Frees the given library
	void					(*FreeLibrary)(void *libHandle);

	// Gets the address of the given procedure from the given library
	void *					(*GetProcAddress)(void *libHandle, const char *procName);

	// Sys_Milliseconds should only be used for profiling purposes, any game
	// related timing information should come from event timestamps
	int						(*Milliseconds)(void);

	// For accurate performance testing
	double					(*GetClockTicks)(void);
	double					(*ClockTicksPerSecond)(void);

	// Returns information about the CPU
	int						(*GetProcessorId)(void);
	const char *			(*GetProcessorString)(void);

	// Prints a message to the console, and possibly to the log file
	void					(*Printf)(const char *fmt, ...);

	// Like Com_Printf, but only prints the message in developer mode
	void					(*DPrintf)(const char *fmt, ...);

	// Throws an error and aborts the current frame. If fatal is true, it will
	// quit to the system console and wait for the user to terminate the
	// program.
	void					(*Error)(bool fatal, const char *fmt, ...);
} odSystem_t;


#endif	// __FRAMEWORK_SYSTEM_H__
